package my.test.status.source;

/**
 * @Author 许玉康
 * @Date 2019-10-30 13:31
 */
public class Context {

    //定义状态
    public static final State state1 = new ConcreteState1();
    public static final State state2 = new ConcreteState2();

    //当前状态
    private State CurrentState;
    //获得当前状态

    public State getCurrentState() {
        return CurrentState;
    }

    public void setCurrentState(State currentState) {
        CurrentState = currentState;
        this.CurrentState.setContext(this);
    }

    //行为委托
    public void handle1() {
        this.CurrentState.handle1();
    }

    public void handle2() {
        this.CurrentState.handle2();
    }
}
